// index.js文件   
Component({
  data: {
      active: 0,
      list: [
        {
          "url": "/pages/index/index",
          "icon": "home-o",
          "text": "主页"
        },
        {
          "url": "/pages/publish/publish",
          "icon": "add",
          "text": "发布"
        },
        {
          "url": "/pages/my/my",
          "icon": "friends-o",
          "text": "我的"
        }
      ]
    },
    methods: {
     onChange(e) {
        // console.log(e,'e')
        wx.switchTab({
          url: this.data.list[e.detail].url
        });
        this.setData({ active: e.detail });
     },
     init() {
         const page = getCurrentPages().pop();
         this.setData({
        　  active: this.data.list.findIndex(item => item.url === `/${page.route}`)
         });
        }
     }
});